
***************************************************************************************************************
/*
THIS DO-FILE:
 gets variables from raw family and individual PSID files,
 creates "PSID_fulldata.dta"
*/
***************************************************************************************************************

clear all
set more off
set maxvar 10000

***************************************************************************************************************

use "$rawPSIDdata/fam1968", clear
#delimit;
keep V93 V95 V47 V3 V398 V196 V198 V181 V81 V74 V75 V76 V79 
     V337 V239 V439 V115 V37 V83 V53 V45 V315 V10 V5 V14 V143 V251 V289;
#delimit cr     
ren V251  wages
ren V14    util          
ren V143  ncars
ren V5    house
ren V10    rent
gen       disab=.
gen      outkid=.
ren V315    vet
ren V45   fstmp
ren V53   hourw
ren V93   state
ren V95    smsa
ren V47   hours
ren V3       id
ren V398   kids
ren V196  empst
ren V198   self
ren V181   race
ren V81       y
ren V74      ly
ren V75     wly
ren V76    tyhw
ren V79   tyoth
gen      troth=0
gen        trhw=y-tyhw-tyoth
ren V337   avhy
ren V239  marit
ren V289 relwalkdis
ren V439 weight
ren V115  fsize
gen       split=0
gen        fchg=0
gen       newhd=0
ren V37    food
gen        fout=.
ren V83    ftax
gen 	    asset=.
gen        trhf=.
gen year=1967
tempfile fam67
save `fam67',replace

use "$rawPSIDdata/fam1969", clear

#delimit;
keep V537 V539 V909 V542 V465 V493 V442 V550 V639 V641 V791 V801 
     V529 V514 V516 V518 V521 V527 V602
     V871 V607 V1014 V500 V506 V532 V525 V475 V510 V796 V732 V743 V455 V449 V460 V581 V699;
#delimit cr
ren V699   wages
ren V460    util 
ren V581   ncars
ren V449   house
ren V455    rent
ren V743   disab
ren V732  outkid
ren V796     vet
ren V510   fstmp
ren V475   hourw
ren V537   state
ren V539    smsa
ren V909   split
ren V542    fchg
ren V465   hours
ren V493   fsize
ren V442      id
ren V550    kids
ren V639   empst
ren V641    self
ren V791   newhd
ren V801    race
ren V529       y
ren V514      ly
ren V516     wly
ren V518    tyhw
ren V521   tyoth
ren V527   troth
ren V525    trhw
ren V871    avhy
ren V607   marit
ren V602 relwalkdis
ren V1014 weight
ren V500    food
ren V506    fout
ren V532    ftax
gen        asset=.
gen         trhf=.
gen year=1968
tempfile fam68
save `fam68',replace

use "$rawPSIDdata/fam1970", clear
#delimit;
keep V1103 V1506 V1106 V1109 V1138 V1167 V1102 V1242 V1278 V1280 V1461 V1490 
     V1514 V1196 V1198 V1205 V1222 V1225 V1220 V1273
     V1567 V1365 V1609 V1175 V1185 V1122 V1208 V1224 V1148 V1183 V1487 V1399 V1409 V1128 V1122 V1133 V1254 V1191;
#delimit cr     
ren V1191   wages
ren V1133    util 
ren V1254   ncars
ren V1122   house
ren V1128    rent
ren V1409   disab
ren V1399  outkid
ren V1487     vet
ren V1183   fstmp
ren V1148   hourw
ren V1103   state
ren V1506    smsa
ren V1106   split
ren V1109    fchg
ren V1138   hours
ren V1167   fsize
ren V1102      id
ren V1242    kids
ren V1278   empst
ren V1280    self
ren V1461   newhd
ren V1490    race
ren V1514       y
ren V1196      ly
ren V1198     wly
ren V1205    tyhw
ren V1222   tyoth
ren V1225   troth
ren V1220    trhw
ren V1567    avhy
ren V1365   marit
ren V1273 relwalkdis
ren V1609  weight
ren V1175    food
ren V1185    fout
gen          ftax=V1208+V1224 if V1208!=. & V1224!=.
replace      ftax=V1208       if V1208!=. & V1224==.
replace      ftax=V1224       if V1208==. & V1224!=.
drop V1208 V1224
gen 	      asset=.
gen          trhf=.
gen year=1969
tempfile fam69
save `fam69',replace

use "$rawPSIDdata/fam1971", clear
#delimit;
keep V1803 V1816 V1806 V1809 V1839 V1868 V1802 V1945 V1983 V1986 V2165 V2202 
     V2226 V1897 V1899 V1906 V1924 V1927 V1922  V1978
     V2279 V2072 V2321 V1876 V1886 V1910 V1926 V1849 V1884 V2199 V2111 V2121 V1829 V1823 V1834 V1957 V1892;
#delimit cr                              
ren V1892   wages
ren V1834    util 
ren V1957   ncars
ren V1823   house
ren V1829    rent
ren V2121   disab
ren V2111  outkid
ren V2199     vet
ren V1884   fstmp
ren V1849   hourw
ren V1803   state
ren V1816    smsa
ren V1806   split
ren V1809    fchg
ren V1839   hours
ren V1868   fsize
ren V1802      id
ren V1945    kids
ren V1983   empst
ren V1986    self
ren V2165   newhd
ren V2202    race
ren V2226       y
ren V1897      ly
ren V1899     wly
ren V1906    tyhw
ren V1924   tyoth
ren V1927   troth
ren V1922    trhw
ren V2279    avhy
ren V2072   marit
ren V1978 relwalkdis
ren V2321  weight
ren V1876    food
ren V1886    fout
gen          ftax=V1910+V1926 if V1910!=. & V1926!=.
replace 	 ftax=V1910       if V1910!=. & V1926==.
replace      ftax=V1926       if V1910==. & V1926!=.
drop V1910 V1926
gen         asset=.
gen          trhf=.
gen year=1970
tempfile fam70
save `fam70',replace

use "$rawPSIDdata/fam1972", clear
#delimit;
keep V2403 V2406 V2407 V2410 V2439 V2468 V2402 V2545 V2581 V2584 V2791 V2828 
     V2852 V2498 V2500 V2507 V2525 V2528 V2523 V2576
     V2906 V2670 V2968 V2476 V2480 V2511 V2527 V2449 V2478 V2825 V2708 V2718 V2429 V2423 V2434 V2557 V2493;
#delimit cr
ren V2493   wages
ren V2434    util 
ren V2557   ncars
ren V2423   house 
ren V2429    rent
ren V2718   disab
ren V2708  outkid
ren V2825     vet
ren V2478   fstmp
ren V2449   hourw
ren V2403   state 
ren V2406    smsa
ren V2407   split
ren V2410    fchg
ren V2439   hours
ren V2468   fsize
ren V2402      id
ren V2545    kids
ren V2581   empst
ren V2584    self
ren V2791   newhd
ren V2828    race
ren V2852       y
ren V2498      ly
ren V2500     wly
ren V2507    tyhw
ren V2525   tyoth
ren V2528   troth
ren V2523    trhw
ren V2906    avhy
ren V2670   marit
ren V2576 relwalkdis
ren V2968  weight
ren V2476    food
ren V2480    fout

gen     ftax=V2511+V2527 if V2511!=. & V2527!=.
replace ftax=V2511       if V2511!=. & V2527==.
replace ftax=V2527       if V2511==. & V2527!=.
drop V2511 V2527
gen asset=.
gen trhf=.
gen year=1971
tempfile fam71
save `fam71',replace

use "$rawPSIDdata/fam1973", clear
#delimit;
keep V3003 V3006 V3007 V3010 V3027 V3017 V3002 V3098 V3114 V3117 V3217 V3300 
     V3256 V3051 V3053 V3060 V3078 V3081 V3076
     V3275 V3181 V3301 V3064 V3080 V3035 V3243 V3211 V3244 V3023 V3021 V3046;
#delimit cr     
ren V3046   wages
gen          util=.
gen         ncars=.
ren V3021   house
ren V3023    rent
ren V3244   disab
ren V3211  outkid
ren V3243     vet
gen        fstmp=.
ren V3035   hourw
ren V3003   state
ren V3006    smsa
ren V3007   split
ren V3010    fchg
ren V3027   hours
ren V3017   fsize
ren V3002      id
ren V3098    kids
ren V3114   empst
ren V3117    self
ren V3217   newhd
ren V3300    race
ren V3256       y
ren V3051      ly
ren V3053     wly
ren V3060    tyhw
ren V3078   tyoth
ren V3081   troth
ren V3076    trhw
ren V3275    avhy
ren V3181   marit
ren V3301  weight
gen food=.
gen fout=.

gen     ftax=V3064+V3080 if V3064!=. & V3080!=.
replace ftax=V3064       if V3064!=. & V3080==.
replace ftax=V3080       if V3064==. & V3080!=.
drop V3064 V3080
gen asset=.
gen trhf=.
gen year=1972
tempfile fam72
save `fam72',replace

use "$rawPSIDdata/fam1974", clear
#delimit;
keep V3403 V3406 V3407 V3410 V3423 V3437 V3402 V3511 V3528 V3532 V3639 V3720 
     V3676 V3463 V3465 V3472 V3490 V3493 V3488
     V3695 V3598 V3721 V3441 V3445 V3476 V3492 V3431 V3443 V3665 V3630 V3666 V3419 V3417 V3458;
#delimit cr     
ren V3458 wages
gen util=.
gen ncars=.
ren V3417 house
ren V3419 rent
ren V3666 disab
ren V3630 outkid
ren V3665 vet
ren V3443   fstmp
ren V3431   hourw
ren V3403   state
ren V3406    smsa
ren V3407   split
ren V3410    fchg
ren V3423   hours
ren V3437   fsize
ren V3402      id
ren V3511    kids
ren V3528   empst
ren V3532    self
ren V3639   newhd
ren V3720    race
ren V3676       y
ren V3463      ly
ren V3465     wly
ren V3472    tyhw
ren V3490   tyoth
ren V3493   troth
ren V3488    trhw
ren V3695    avhy
ren V3598   marit
ren V3721  weight
ren V3441    food
ren V3445    fout

gen         ftax=V3476+V3492 if V3476!=. & V3492!=.
replace     ftax=V3476       if V3476!=. & V3492==.
replace     ftax=V3492       if V3476==. & V3492!=.
drop V3476 V3492
gen 	     asset=.
gen         trhf=.
gen year=1973
tempfile fam73
save `fam73',replace

use "$rawPSIDdata/fam1975", clear
#delimit;
keep V3803 V3806 V3807 V3810 V3823 V3837 V3802 V3924 V3967 V3970 V4114 V4204 
     V4154 V3863 V3865 V3872 V3891 V3905 V3889
     V4174 V4053 V4224 V3841 V3853 V3876 V3893 V3831 V3851 V4140 V4076 V4145 V3819 V3817 V3931 V3858;
#delimit cr     
ren V3858   wages
gen          util=.    
ren V3931   ncars
ren V3817   house
ren V3819    rent
ren V4145   disab
ren V4076  outkid
ren V4140     vet
ren V3851   fstmp
ren V3831   hourw
ren V3803   state
ren V3806    smsa
ren V3807   split
ren V3810    fchg
ren V3823   hours
ren V3837   fsize
ren V3802      id
ren V3924    kids
ren V3967   empst
ren V3970    self
ren V4114   newhd
ren V4204    race
ren V4154       y
ren V3863      ly
ren V3865     wly
ren V3872    tyhw
ren V3891   tyoth
ren V3905   troth
ren V3889    trhw
ren V4174    avhy
ren V4053   marit
ren V4224  weight
ren V3841    food
ren V3853    fout

gen          ftax=V3876+V3893 if V3876!=. & V3893!=.
replace 	 ftax=V3876       if V3876!=. & V3893==.
replace 	 ftax=V3893       if V3876==. & V3893!=.
drop V3876 V3893
gen 		asset=.
gen 		 trhf=.
gen year=1974
tempfile fam74
save `fam74',replace

use "$rawPSIDdata/fam1976", clear
#delimit;
keep V4303 V4306 V4307 V4310 V4332 V4346 V4302 V4439 V4458 V4461 V4658 V5096 
     V5029 V5031 V4379 V4386 V4406 V4419 V4404
     V5050 V4603 V5099 V4354 V4368 V4390 V4409 V5076 V4344 V4364 V4683 V4620 V4625 V4326 V4318 V4446 V4373;
#delimit cr          
ren V4373 wages
gen 		 util=.   
ren V4446   ncars
ren V4318   house
ren V4326    rent
ren V4625   disab
ren V4620  outkid
ren V4683     vet
ren V4364   fstmp
ren V4344   hourw
ren V4303   state
ren V4306    smsa
ren V4307   split
ren V4310    fchg
ren V4332   hours
ren V4346   fsize
ren V4302      id
ren V4439    kids
ren V4458   empst
ren V4461    self
ren V4658   newhd
ren V5096    race
ren V5029       y
ren V5031      ly
ren V4379     wly
ren V4386    tyhw
ren V4406   tyoth
ren V4419   troth
ren V4404    trhw
ren V5050    avhy
ren V4603   marit
ren V5099  weight
ren V4354    food
ren V4368    fout

gen          ftax=V4390+V4409  if V4390!=. & V4409!=.
replace 	 ftax=V4390        if V4390!=. & V4409==.
replace 	 ftax=V4409        if V4390==. & V4409!=.
replace 	 ftax=ftax-V5076 if V5076!=.
gen 		asset=.
gen 		 trhf=.
drop V4390 V4409 V5076
gen year=1975
tempfile fam75
save `fam75',replace

use "$rawPSIDdata/fam1977", clear
#delimit;
keep V5203 V5206 V5207 V5210 V5232 V5254 V5202 V5353 V5373 V5376 V5578 V5662 
     V5626 V5627 V5289 V5297 V5318 V5332 V5316
     V5631 V5650 V5665 V5271 V5273 
     V5301 V5321 V5649 V5244 V5277 V5603 V5555 V5560 V5225 V5217 V5231 V5360 V5283;
#delimit cr

ren V5283   wages
ren V5231    util 
ren V5360   ncars
ren V5217   house
ren V5225    rent
ren V5560   disab
ren V5555  outkid
ren V5603     vet
ren V5277   fstmp
ren V5244   hourw
ren V5203   state
ren V5206    smsa
ren V5207   split
ren V5210    fchg
ren V5232   hours
ren V5254   fsize
ren V5202      id
ren V5353    kids
ren V5373   empst
ren V5376    self
ren V5578   newhd
ren V5662    race
ren V5626       y
ren V5627      ly
ren V5289     wly
ren V5297    tyhw
ren V5318   tyoth
ren V5332   troth
ren V5316    trhw
ren V5631    avhy
ren V5650   marit
ren V5665  weight
ren V5271    food
ren V5273    fout

gen     ftax=V5301+V5321  if V5301!=. & V5321!=.
replace ftax=V5301        if V5301!=. & V5321==.
replace ftax=V5321        if V5301==. & V5321!=.
replace ftax=ftax-V5649 if V5649!=.
drop V5301 V5321 V5649
gen asset=.
gen trhf=.
gen year=1976
tempfile fam76
save `fam76',replace

use "$rawPSIDdata/fam1978", clear
#delimit;
keep V5703 V5706 V5707 V5710 V5731 V5755 V5702 V5853 V5782 V5875 V6127 V6209 
     V6173 V6174 V5788 V5796 V5817 V5831 V5815
     V6178 V6197 V6212 V5770 V5772 V5800 V5820 V6196 V5743 V5815 V5831 V5776 V6152 V6097 V6102 V5723 V5717 V5729 V5860 V5872;
#delimit cr          
ren V5782   wages
ren V5729    util 
ren V5860   ncars
ren V5717   house
ren V5723    rent
ren V6102   disab
ren V6097  outkid
ren V6152     vet
ren V5776   fstmp
ren V5815    trhw 
ren V5743   hourw
ren V5703   state
ren V5706    smsa
ren V5707   split
ren V5710    fchg
ren V5731   hours
ren V5755   fsize
ren V5702      id
ren V5853    kids
ren V5872   empst
ren V5875    self
ren V6127   newhd
ren V6209    race
ren V6173       y
ren V6174      ly
ren V5788     wly
ren V5796    tyhw
ren V5817   tyoth
ren V5831   troth
ren V6178    avhy
ren V6197   marit
ren V6212  weight
ren V5770    food
ren V5772    fout
gen     ftax=V5800+V5820  if V5800!=. & V5820!=.
replace ftax=V5800        if V5800!=. & V5820==.
replace ftax=V5820        if V5800==. & V5820!=.
replace ftax=ftax-V6196 if V6196!=.
drop V5800 V5820 V6196
gen asset=.
gen year=1977
tempfile fam77
save `fam77',replace

use "$rawPSIDdata/fam1979", clear
gen truncy	=V6766==99999												/*From now on, define {0,1} for topcoded income*/
gen trunca	=V6400==99999|V6401==99999|V6402==9999 |V6404==99999|V6400==-9999|V6402==-999		/*From now on, define {0,1} for topcoded financial income*/
#delimit;
keep V6303 V6306 V6307 V6310 V6336 V6361 V6302 V6465 V6492 V6493 V6724 V6802 
     V6766 V6767 V6398 V6408 V6428 V6442 V6426
     V6771 V6790 V6805 V6376 V6378 V6411 V6431 V6789 V6348
     V6400-V6406 V6430 V6426 V6442 V6382 V6749 V6690 V6710 V6326 V6319 V6332 V6473 V6391 V6495 V6496 V6422 V6440 trunc*
	 V6409 V6422 V6440
	 ;
#delimit cr
gen     aoth=0            if V6430==0
replace aoth=V6428*0.01   if V6430==1
replace aoth=V6428*0.0375 if V6430==2
replace aoth=V6428*0.085  if V6430==3
replace aoth=V6428*0.1125 if V6430==4
replace aoth=V6428*0.2    if V6430==5
replace aoth=V6428*0.3    if V6430==6
replace aoth=V6428*0.35   if V6430==7
replace aoth=V6428*0.5    if V6430==8
        
ren V6495 unionj  
ren V6496 unioni  
gen asset=V6400+V6401+V6402+V6403+V6404+V6405+V6406+aoth
drop      V6400-V6406 aoth
ren V6391   wages
ren V6332    util
ren V6473   ncars
ren V6319   house
ren V6326    rent
ren V6710   disab
ren V6690  outkid
ren V6749     vet
ren V6382   fstmp
ren V6348   hourw
ren V6303   state
ren V6306    smsa
ren V6307   split
ren V6310    fchg
ren V6336   hours
ren V6361   fsize
ren V6302      id
ren V6465    kids
ren V6492   empst
ren V6493    self
ren V6724   newhd
ren V6802    race
ren V6766       y
ren V6767      ly
ren V6398     wly
ren V6408    tyhw
ren V6428   tyoth
ren V6442   troth
ren V6426    trhw
ren V6409 giveamt
ren V6422 increlh
ren V6440 increlofum
ren V6771    avhy
ren V6790   marit
ren V6805  weight
ren V6376    food
ren V6378    fout
gen     	 ftax=V6411+V6431  if V6411!=. & V6431!=.
replace 	 ftax=V6411        if V6411!=. & V6431==.
replace 	 ftax=V6431        if V6411==. & V6431!=.
replace 	 ftax=ftax-V6789 if V6789!=.
drop V6411 V6431 V6789 V6430
gen year=1978
tempfile fam78
save `fam78',replace

use "$rawPSIDdata/fam1980", clear
gen truncy	=V7412==999999
gen trunca	=V6992==9999 |V6994==99999|V6990==-9999|V6991==-9999|V6992==-999
#delimit;
keep V6903 V6906 V6907 V6910 V6934 V6959 V6902 V7070 V7095 V7096 V7357 V7447 
     V7412 V7413 V6988 V6998 V7033 V7046 V7016
     V7417 V7435 V7451 V6972 V6974 V7399 V7411 V6946
     V6990-V6996 V7035 V7016 V7046 V6976 V7382 V7293 V7343 V6925 V6917 V6931 V7078 V6981 trunc* 
	 V7098 V7099 V7012 V7044 V6999 V7012 V7044
	 ;
#delimit cr          
gen     aoth=0            if V7035==0
replace aoth=V7033*0.01   if V7035==1
replace aoth=V7033*0.0375 if V7035==2
replace aoth=V7033*0.085  if V7035==3
replace aoth=V7033*0.1125 if V7035==4
replace aoth=V7033*0.2    if V7035==5
replace aoth=V7033*0.3    if V7035==6
replace aoth=V7033*0.35   if V7035==7
replace aoth=V7033*0.5    if V7035==8
gen asset=V6990+V6991+V6992+V6993+V6994+V6995+V6996+aoth
drop      V6990-V6996 aoth
ren V7098 unionj  
ren V7099 unioni  
ren V6981 	wages
ren V6931    util 
ren V7078   ncars
ren V6917 	house
ren V6925 	 rent
ren V7343 	disab
ren V7293  outkid
ren V7382     vet
ren V6976   fstmp
ren V6946   hourw
ren V6903   state
ren V6906    smsa
ren V6907   split
ren V6910    fchg
ren V6934   hours
ren V6959   fsize
ren V6902      id
ren V7070    kids
ren V7095   empst
ren V7096    self
ren V7357   newhd
ren V7447    race
ren V7412       y
ren V7413      ly
ren V6988     wly
ren V6998    tyhw
ren V7033   tyoth
ren V7046   troth
ren V7016    trhw
ren V7417    avhy
ren V6999 giveamt
ren V7012 increlh
ren V7044 increlofum
ren V7435   marit
ren V7451  weight
ren V6972    food
ren V6974    fout
gen     	 ftax=V7399+V7411 if V7399!=. & V7411!=.
replace 	 ftax=V7399       if V7399!=. & V7411==.
replace 	 ftax=V7411       if V7399==. & V7411!=.
drop V7399 V7411 V7035
gen year=1979
tempfile fam79
save `fam79',replace


use "$rawPSIDdata/fam1981", clear
gen truncy	=V8065==9999999
gen trunca	=V7586==99999|V7587==9999|V7584==-9999
#delimit;
keep V7503 V7506 V7507 V7510 V7530 V7551 V7502 V7661 V7706 V7707 V8009 V8099 
     V8065 V8066 V7580 V7590 V7625 V7638 V7608
     V8069 V8087 V8103 V7564 V7566 V8052 V8064 V7540
     V7582-V7588 V7627 V7608 V7638 V7568 V8034 V7993 V7974 V7525 V7517 V7699 V7669 V7573 trunc* 
	 V7709 V7710 V7604 V7636 V7591 V7604 V7636
	 ;
#delimit cr
ren V7709 unionj  
ren V7710 unioni  
gen     aoth=0            if V7627==0
replace aoth=V7625*0.01   if V7627==1
replace aoth=V7625*0.0375 if V7627==2
replace aoth=V7625*0.085  if V7627==3
replace aoth=V7625*0.1125 if V7627==4
replace aoth=V7625*0.2    if V7627==5
replace aoth=V7625*0.3    if V7627==6
replace aoth=V7625*0.35   if V7627==7
replace aoth=V7625*0.5    if V7627==8
gen asset=V7582+V7583+V7584+V7585+V7586+V7587+V7588+aoth
drop V7582-V7588 aoth    
ren V7573   wages
ren V7699    util 
ren V7669   ncars
ren V7517   house
ren V7525    rent
ren V7974   disab
ren V7993  outkid
ren V8034 	  vet
ren V7568   fstmp
ren V7540   hourw
ren V7503   state
ren V7506    smsa
ren V7507   split
ren V7510    fchg
ren V7530   hours
ren V7551   fsize
ren V7502      id
ren V7661    kids
ren V7706   empst
ren V7707    self
ren V8009   newhd
ren V8099    race
ren V8065       y
ren V8066      ly
ren V7580     wly
ren V7590    tyhw
ren V7625   tyoth
ren V7638   troth
ren V7608    trhw
ren V8069    avhy
ren V7591 giveamt
ren V7604 increlh
ren V7636 increlofum
ren V8087   marit
ren V8103  weight
ren V7564    food
ren V7566    fout
gen     	 ftax=V8052+V8064 if V8052!=. & V8064!=.
replace 	 ftax=V8052       if V8052!=. & V8064==.
replace 	 ftax=V8064       if V8052==. & V8064!=.
drop V8052 V8064 V7627
gen year=1980
tempfile fam80
save `fam80',replace


use "$rawPSIDdata/fam1982", clear
gen truncy	=V8689==999999
gen trunca	=V8275==99999|V8276==99999|V8277==99999|V8277==-9999|V8278==99999|V8279==99999|V8280==9999 |V8281==99999
#delimit;
keep V8203 V8206 V8207 V8210 V8228 V8249 V8202 V8355 V8374 V8375 V8633 V8723 
     V8689 V8690 V8273 V8283 V8318 V8331 V8301
     V8693 V8711 V8727 V8256 V8258 V8676 V8688 V8238
     V8275-V8281 V8320 V8301 V8331 V8260 V8658 V8612 V8616 V8221 V8217 V8225 V8358 V8265 trunc* 
	 V8377 V8378 V8297 V8329 V8284 V8297 V8329
	 ;
#delimit cr           
  
gen     aoth=0            if V8320==0
replace aoth=V8318*0.01   if V8320==1
replace aoth=V8318*0.0375 if V8320==2
replace aoth=V8318*0.085  if V8320==3
replace aoth=V8318*0.1125 if V8320==4
replace aoth=V8318*0.2    if V8320==5
replace aoth=V8318*0.3    if V8320==6
replace aoth=V8318*0.35   if V8320==7
replace aoth=V8318*0.5    if V8320==8
gen asset=V8275+V8276+V8277+V8278+V8279+V8280+V8281+aoth
drop V8275-V8281 aoth

ren V8377 unionj  
ren V8378 unioni  
ren V8265   wages
ren V8225    util 
ren V8358   ncars
ren V8217   house
ren V8221    rent
ren V8616   disab
ren V8612  outkid
ren V8658     vet
ren V8260   fstmp
ren V8238   hourw
ren V8203   state
ren V8206    smsa
ren V8207   split
ren V8210    fchg
ren V8228   hours
ren V8249   fsize
ren V8202      id
ren V8355    kids
ren V8374   empst
ren V8375    self
ren V8633   newhd
ren V8723    race
ren V8689       y
ren V8690      ly
ren V8273     wly
ren V8283    tyhw
ren V8318   tyoth
ren V8331   troth
ren V8301    trhw
ren V8693    avhy
ren V8284 giveamt
ren V8297 increlh
ren V8329 increlofum
ren V8711   marit
ren V8727  weight
ren V8256    food
ren V8258    fout
gen     	 ftax=V8676+V8688 if V8676!=. & V8688!=.
replace 	 ftax=V8676       if V8676!=. & V8688==.
replace 	 ftax=V8688       if V8676==. & V8688!=.
drop V8676 V8688 V8320
gen year=1981
tempfile fam81
save `fam81',replace

use "$rawPSIDdata/fam1983", clear
gen truncy	=V9375==9999999
gen trunca	=V8883==999999|V8884==999999|V8885==99999 |V8885==-9999 |V8886==99999 |V8887==999999|V8888==99999 |V8889==99999
#delimit;
keep V8803 V8806 V8807 V8810 V8830 V8851 V8802 V8964 V9005 V9006 V9319 V9408 
     V9375 V9376 V8881 V8891 V8926 V8939 V8909
     V9379 V9419 V9433 V8864 V8866 V9362 V9374 V8840
     V8883-V8889 V8928 V8909 V8939 V8868 V9344 V9303 V9290 V8825 V8817 V8998 V8967 V8873 trunc* 
	 V9008 V9009 V8905 V8937 V8892 V8905 V8937
	 ;
#delimit cr       

ren V9008 unionj  
ren V9009 unioni  
gen asset=V8883+V8884+V8885+V8886+V8887+V8888+V8889+V8928
drop V8883-V8889 V8928  
ren V8873   wages
ren V8998    util
ren V8967   ncars
ren V8817   house
ren V8825    rent
ren V9290   disab
ren V9303  outkid
ren V9344     vet
ren V8868   fstmp
ren V8840   hourw
ren V8803   state
ren V8806    smsa
ren V8807   split
ren V8810    fchg
ren V8830   hours
ren V8851   fsize
ren V8802      id
ren V8964    kids
ren V9005   empst
ren V9006    self
ren V9319   newhd
ren V9408    race
ren V9375       y
ren V9376      ly
ren V8881     wly
ren V8891    tyhw
ren V8926   tyoth
ren V8939   troth
ren V8909    trhw
ren V9379    avhy
ren V8892 giveamt
ren V8905 increlh
ren V8937 increlofum
ren V9419   marit
ren V9433  weight
ren V8864    food
ren V8866    fout
gen          ftax=V9362+V9374 if V9362!=. & V9374!=.
replace      ftax=V9362       if V9362!=. & V9374==.
replace      ftax=V9374       if V9362==. & V9374!=.
drop V9362 V9374
gen year=1982
tempfile fam82
save `fam82',replace

use "$rawPSIDdata/fam1984", clear
gen truncy	=V11022==999999
gen trunca	=V10265==999999|V10266==999999|V10267==99999 |V10268==99999 |V10270==999999|V10272==999999|V10274==99999 |V10275==999999|V10276==-9999
#delimit;
keep V10003 V10006 V10007 V10010 V10037 V10222 V10002 V10422 V10453 V10456 V10966 V11055 
     V11022 V11023 V10263 V10277 V10382 V10396 V10305
     V11026 V11065 V11079 V10235 V10237 V11009 V11021 V10131
     V10265-V10268 V10270 V10272 V10274 V10275 V10384 V10305 V10396 V10239 V10991 V10894 
	 V10879 V10026 V10018 V10030 V10430 V10256 trunc*  
     V10458 V10459 V10300 V10394 V10278 V10300 V10394
	 ;
#delimit cr

ren V10458 unionj 
ren V10459 unioni 
gen asset=V10265+V10266+V10267+V10268+V10270+V10272+V10274+V10275+V10384
drop V10265-V10268 V10270 V10272 V10274 V10275 V10384
ren V10256   wages
ren V10030    util 
ren V10430   ncars
ren V10018   house
ren V10026    rent
ren V10879   disab
ren V10894  outkid
ren V10991     vet
ren V10239   fstmp
ren V10131   hourw
ren V10003   state
ren V10006    smsa
ren V10007   split
ren V10010    fchg
ren V10037   hours
ren V10222   fsize
ren V10002      id
ren V10422    kids
ren V10453   empst
ren V10456    self
ren V10966   newhd
ren V11055    race
ren V11022       y
ren V11023      ly
ren V10263     wly
ren V10277    tyhw
ren V10382   tyoth
ren V10396   troth
ren V10305    trhw
ren V11026    avhy
ren V10278 giveamt
ren V10300 increlh
ren V10394 increlofum
ren V11065   marit
ren V11079  weight
ren V10235    food
ren V10237    fout
gen           ftax=V11009+V11021 if V11009!=. & V11021!=.
replace       ftax=V11009       if V11009!=. & V11021==.
replace       ftax=V11021       if V11009==. & V11021!=.
drop V11009 V11021
gen year=1983
tempfile fam83
save `fam83',replace

use "$rawPSIDdata/fam1985", clear
gen truncy	=V12371==999999
gen trunca	=V11406==999999|V11407==999999|V11408==99999 |V11406==-99999|V11407==-99999|V11408==-9999 |V11409==99999 |V11412==999999|V11414==999999| ///		
		 V11416==999999|V11417==999999
#delimit;
keep V11103 V11106 V11107 V11112 V11146 V11364 V11102 V11609 V11637 V11640 V11906 V11938 
     V12371 V12372 V11404 V11419 V11561 V11577 V11461
     V12377 V12426 V12446 V11375 V11377 V12358 V12370 V11258
     V11406-V11409 V11412  V11414  V11416 V11417 V11563 V11461 V11577 V11379 V11940 V11896 V11993 V11133 V11125 V11137 V11635 V11397 trunc* 
     V11649 V11650 V11445 V11457 V11574 V11420 V11421 V11422 V11445 V11457 V11574
;
#delimit cr

ren V11649 unionj 
ren V11650 unioni 

gen asset=V11406+V11407+V11408+V11409+V11412+V11414+V11416+V11417+V11563
drop 	V11406-V11409 V11412  V11414  V11416 V11417 V11563
ren V11397   wages
ren V11137    util 
ren V11635   ncars
ren V11125   house
ren V11133    rent
ren V11993   disab
ren V11896  outkid
ren V11940     vet
ren V11379   fstmp
ren V11258   hourw
ren V11103   state
ren V11106    smsa
ren V11107   split
ren V11112    fchg
ren V11146   hours
ren V11364   fsize
ren V11102      id
ren V11609    kids
ren V11637   empst
ren V11640    self
ren V11906   newhd
ren V11938    race
ren V12371       y
ren V12372      ly
ren V11404     wly
ren V11419    tyhw
ren V11561   tyoth
ren V11577   troth
ren V11461    trhw
ren V12377    avhy
ren V11420 giveamt
ren V11421 givechsup
ren V11422 givealim
ren V11445 increlh
ren V11457 increlw
ren V11574 increlofum
ren V12426   marit
ren V12446  weight
ren V11375    food
ren V11377    fout
gen           ftax=V12358+V12370 if V12358!=. & V12370!=.
replace       ftax=V12358       if V12358!=. & V12370==.
replace       ftax=V12370       if V12358==. & V12370!=.
drop V12358 V12370
gen year=1984
tempfile fam84
save `fam84',replace


use "$rawPSIDdata/fam1986", clear
gen truncy	=V13623==999999
gen trunca	=V12806==-99999|V12807==-9999
#delimit;
keep V12503 V12506 V12507 V12510 V12545 V12763 V12502 V13014 V13046 V13049 V13533 V13565 
     V13623 V13624 V12803 V12818 V12968 V12984 V12868
     V13629 V13665 V13687 V12774 V12776 V13610 V13622 V12657
     V12805-V12808  V12811  V12813  V12815 V12816 V12970 V12868 V12984 V12778 V13567 V13407 V13427 V12532 V12524 V12536 V13044 V12796 trunc*
	 V13052 V13053 V12844 V12864 V12981 V12819 V12820 V12821 V12844 V12864 V12981
;
#delimit cr 

ren V13052 unionj 
ren V13053 unioni 
 
gen asset=V12805+V12806+V12807+V12808+V12811+V12813+V12815+V12816+V12970
drop V12805-V12808  V12811  V12813  V12815 V12816 V12970
ren V12796   wages
ren V12536    util 
ren V13044   ncars
ren V12524   house
ren V12532    rent
ren V13427   disab
ren V13407  outkid
ren V13567     vet
ren V12778   fstmp
ren V12657   hourw
ren V12503   state
ren V12506    smsa
ren V12507   split
ren V12510    fchg
ren V12545   hours
ren V12763   fsize
ren V12502      id
ren V13014    kids
ren V13046   empst
ren V13049    self
ren V13533   newhd
ren V13565    race
ren V13623       y
ren V13624      ly
ren V12803     wly
ren V12818    tyhw
ren V12968   tyoth
ren V12984   troth
ren V12868    trhw
ren V13629    avhy
ren V12819 giveamt
ren V12820 givechsup
ren V12821 givealim
ren V12844 increlh
ren V12864 increlw
ren V12981 increlofum
ren V13665   marit
ren V13687  weight
ren V12774    food
ren V12776    fout
gen           ftax=V13610+V13622 if V13610!=. & V13622!=.
replace       ftax=V13610       if V13610!=. & V13622==.
replace       ftax=V13622       if V13610==. & V13622!=.
drop V13610 V13622
gen year=1985
tempfile fam85
save `fam85',replace


use "$rawPSIDdata/fam1987", clear
gen truncy=V14670==999999
gen trunca=V13909==-9999
#delimit;
keep V13703 V13706 V13707 V13710 V13745 V13867 V13702 V14117 V14146 V14149 V14580 V14612 
     V14670 V14671 V13905 V13920 V14070 V14086 V13970
     V14676 V14712 V14737 V13876 V13878 V14657 V14669 V13809
     V13907-V13910 V13913 V13915 V13917 V13918 V14072 V13970 V14086 V13880 V14614 V14504 V14515 V13732 V13724 V13736 V13898 trunc*
     V14152 V14153 V13946 V13966 V14083
	 V13921 V13922 V13923 V13946 V13966
;
#delimit cr

ren V14152 unionj 
ren V14153 unioni 
gen asset=V13907+V13908+V13909+V13910+V13913+V13915+V13917+V13918+V14072
drop V13907 V13908 V13909 V13910 V13913 V13915 V13917 V13918 V14072
gen  ncars=.
ren V13898   wages
ren V13736    util
ren V13724   house
ren V13732    rent
ren V14515   disab
ren V14504  outkid
ren V14614     vet
ren V13880   fstmp
ren V13809   hourw
ren V13703   state
ren V13706    smsa
ren V13707   split
ren V13710    fchg
ren V13745   hours
ren V13867   fsize
ren V13702      id
ren V14117    kids
ren V14146   empst
ren V14149    self
ren V14580   newhd
ren V14612    race
ren V14670       y
ren V14671      ly
ren V13905     wly
ren V13920    tyhw
ren V14070   tyoth
ren V14086   troth
ren V13970    trhw
ren V14676    avhy
ren V13921 giveamt
ren V13922 givechsup
ren V13923 givealim
ren V13946 increlh
ren V13966 increlw
ren V14083 increlofum
ren V14712   marit
ren V14737  weight
ren V13876    food
ren V13878    fout
gen           ftax=V14657+V14669 if V14657!=. & V14669!=.
replace       ftax=V14657        if V14657!=. & V14669==.
replace       ftax=V14669        if V14657==. & V14669!=.
drop V14657 V14669
gen year=1986
tempfile fam86
save `fam86',replace

use "$rawPSIDdata/fam1988", clear
gen truncy=V16144==9999999
gen trunca=V14924==-9999
#delimit;
keep V14803 V14806 V14807 V14810 V14835 V14889 V14802 V15133 V15154 V15157 V16054 V16086 
     V16144 V16145 V14920 V14935 V15085 V15101 V14985
     V16150 V16187 V16208 V16131 V16143 V14865
     V14922-V14925 V14928 V14930 V14932 V14933 V15087 V14985 V15101 V14895 V16088 V15779 V15994 V14824 V14913 trunc*
     V15160 V15161 V14961 V14981 V15098 
	 V14936 V14937 V14938 V14981 V15098
;
#delimit cr

ren V15160 unionj
ren V15161 unioni 

gen asset=V14922+V14923+V14924+V14925+V14928+V14930+V14932+V14933+V15087
drop V14922-V14925 V14928 V14930 V14932 V14933 V15087
gen  ncars=.
gen   util=.
gen    rent=.
ren V14913   wages
ren V14824   house
ren V15994   disab
ren V15779  outkid
ren V16088     vet
ren V14895   fstmp
ren V14865   hourw
ren V14803   state
ren V14806    smsa
ren V14807   split
ren V14810    fchg
ren V14835   hours
ren V14889   fsize
ren V14802      id
ren V15133    kids
ren V15154   empst
ren V15157    self
ren V16054   newhd
ren V16086    race
ren V16144       y
ren V16145      ly
ren V14920     wly
ren V14935    tyhw
ren V15085   tyoth
ren V15101   troth
ren V14985    trhw
ren V16150    avhy
ren V14936 giveamt
ren V14937 givechsup
ren V14938 givealim
ren V14961 increlh
ren V14981 increlw
ren V15098 increlofum
ren V16187   marit
ren V16208  weight
gen 		  food=.
gen 		  fout=.
gen           ftax=V16131+V16143 if V16131!=. & V16143!=.
replace       ftax=V16131        if V16131!=. & V16143==.
replace       ftax=V16143        if V16131==. & V16143!=.
drop V16131 V16143
gen year=1987
tempfile fam87
save `fam87',replace

use "$rawPSIDdata/fam1989", clear
gen truncy=V17533==9999999
gen trunca=V16424==-99999
#delimit;
keep V16303 V16306 V16307 V16310 V16335 V16389 V16302 V16634 V16655 V16658 V17451 V17483 
     V17533 V17534 V16420 V16435 V16585 V16601 V16485 
     V17536 V17565 V17612 V17528 V17532 V16365
     V16422-V16425 V16428 V16430 V16432 V16433 V16587 V16485 V16601 V16395 V17485 V17308 V17391 V16324 V16413 trunc* 
	 V16661 V16662 V16461 V16481 V16598
	 V16436 V16437 V16438 V16461 V16481 V16598
;
#delimit cr

ren V16661 unionj 
ren V16662 unioni 

gen asset=V16422+V16423+V16424+V16425+V16428+V16430+V16432+V16433+V16587
drop V16422-V16425 V16428 V16430 V16432 V16433 V16587
gen    rent=.
gen  ncars=.
gen   util=.
ren V16413   wages
ren V16324   house
ren V17391   disab
ren V17308  outkid
ren V17485     vet
ren V16395   fstmp
ren V16365   hourw
ren V16303   state
ren V16306    smsa
ren V16307   split
ren V16310    fchg
ren V16335   hours
ren V16389   fsize
ren V16302      id
ren V16634    kids
ren V16655   empst
ren V16658    self
ren V17451   newhd
ren V17483    race
ren V17533       y
ren V17534      ly
ren V16420     wly
ren V16435    tyhw
ren V16585   tyoth
ren V16601   troth
ren V16485    trhw
ren V17536    avhy
ren V16436 giveamt
ren V16437 givechsup
ren V16438 givealim
ren V16461 increlh
ren V16481 increlw
ren V16598 increlofum
ren V17565   marit
ren V17612  weight
gen food=.
gen fout=.
gen          ftax=V17528+V17532 if V17528!=. & V17532!=.
replace      ftax=V17528       if V17528!=. & V17532==.
replace      ftax=V17532       if V17528==. & V17532!=.
drop V17528 V17532
gen year=1988
tempfile fam88
save `fam88',replace


use "$rawPSIDdata/fam1990", clear
gen truncy=V18875==9999999
gen trunca=V17838==999999
#delimit;
keep V17703 V17706 V17707 V17710 V17744 V17798 V17702 V18052 V18093 V18096 V18782 V18814 
     V18875 V18878 V17836 V17851 V18001 V18017 V17901 
     V18887 V18916 V18943 V17807 V17809 V18862 V18874 V17774
     V17838-V17841 V17844 V17846 V17848 V17849 V18003 V17901 V18017 V17811 V18816 V18712 V18722 V17733 V17724 V17829 trunc*
	 V18099 V18100 V17877 V17897 V18014
	 V17852 V17853 V17854 V17877 V17897 V18014
;
#delimit cr

ren V18099 unionj 
ren V18100 unioni 

gen asset=V17838+V17839+V17840+V17841+V17844+V17846+V17848+V17849+V18003 
drop V17838-V17841 V17844 V17846 V17848 V17849 V18003
gen  ncars=.
gen   util=.
ren V17829   wages
ren V17724   house
ren V17733    rent
ren V18722   disab
ren V18712  outkid
ren V18816     vet
ren V17811   fstmp
ren V17774   hourw
ren V17703   state
ren V17706    smsa
ren V17707   split
ren V17710    fchg
ren V17744   hours
ren V17798   fsize
ren V17702      id
ren V18052    kids
ren V18093   empst
ren V18096    self
ren V18782   newhd
ren V18814    race
ren V18875       y
ren V18878      ly
ren V17836     wly
ren V17851    tyhw
ren V18001   tyoth
ren V18017   troth
ren V17901    trhw
ren V18887    avhy
ren V17852 giveamt
ren V17853 givechsup
ren V17854 givealim
ren V17877 increlh
ren V17897 increlw
ren V18014 increlofum
ren V18916   marit
ren V18943  weight
ren V17807    food
ren V17809    fout
replace V18862=. if V18862==999999
replace V18874=. if V18874==999999
gen          ftax=V18862+V18874 if V18862!=. & V18874!=.
replace      ftax=V18862        if V18862!=. & V18874==.
replace      ftax=V18874        if V18862==. & V18874!=.
drop V18862 V18874
gen year=1989
tempfile fam89
save `fam89',replace


use "$rawPSIDdata/fam1991", clear
gen truncy=V20175==999999
gen trunca=V19139==-99999|V19140==-9999
#delimit;
keep V19003 V19006 V19007 V19010 V19044 V19098 V19002 V19352 V19393 V19396 V20082 V20114 
     V20175 V20178 V19136 V19151 V19301 V19317 V19201 
     V20187 V20216 V20243 V19107 V19109 V20162 V20174 V19074
     V19138-V19141 V19144 V19146 V19148 V19149 V19303 V19201 V19317 V19111 V20116 V20012 V20022 V19033 V19024 V19129 trunc* 
	 V19399 V19400 V19177 V19197 V19314
	 V19152 V19153 V19154 V19177 V19197 V19314
;
#delimit cr

ren V19399 unionj 
ren V19400 unioni 

gen asset=V19138+V19139+V19140+V19141+V19144+V19146+V19148+V19149+V19303
drop V19138-V19141 V19144 V19146 V19148 V19149 V19303
gen  ncars=.
gen   util=.
ren V19129   wages
ren V19024   house
ren V19033    rent
ren V20022   disab
ren V20012  outkid
ren V20116     vet
ren V19111   fstmp
ren V19074   hourw
ren V19003   state
ren V19006    smsa
ren V19007   split
ren V19010    fchg
ren V19044   hours
ren V19098   fsize
ren V19002      id
ren V19352    kids
ren V19393   empst
ren V19396    self
ren V20082   newhd
ren V20114    race
ren V20175       y
ren V20178      ly
ren V19136     wly
ren V19151    tyhw
ren V19301   tyoth
ren V19317   troth
ren V19201    trhw
ren V20187    avhy
ren V19152 giveamt
ren V19153 givechsup
ren V19154 givealim
ren V19177 increlh
ren V19197 increlw
ren V19314 increlofum
ren V20216   marit
ren V20243  weight
ren V19107    food
ren V19109    fout
gen           ftax=V20162+V20174 if V20162!=. & V20174!=.
replace       ftax=V20162       if V20162!=. & V20174==.
replace       ftax=V20174       if V20162==. & V20174!=.
drop V20162 V20174
gen year=1990
tempfile fam90
save `fam90',replace

use "$rawPSIDdata/fam1992", clear
gen truncy=V21481==9999999
gen trunca=V20440==-9999
#delimit;
keep V20303 V20306 V20307 V20310 V20344 V20398 V20302 V20654 V20693 V20696 V21388 V21420 
     V21481 V21484 V20436 V20451 V20601 V20617 V20501 
     V21493 V21522 V21547 V20407 V20409 V20374
     V20438-V20441 V20444 V20446 V20448 V20449 V20603 V20501 V20617 V20411 V21422 V21312 V21322 V20333 V20324 V20429 trunc* 
     V20699 V20700 V20477 V20497 V20614
	 V20452 V20453 V20454 V20477 V20497 V20614
;
#delimit cr
ren V20699 unionj 
ren V20700 unioni 

gen asset=V20438+V20439+V20440+V20441+V20444+V20446+V20448+V20449+V20603
drop V20438-V20441 V20444 V20446 V20448 V20449 V20603
gen  ncars=.
gen   util=.
ren V20429   wages
ren V20324   house
ren V20333    rent
ren V21322   disab
ren V21312  outkid
ren V21422     vet
ren V20411   fstmp
ren V20374   hourw
ren V20303   state
ren V20306    smsa
ren V20307   split
ren V20310    fchg
ren V20344   hours
ren V20398   fsize
ren V20302      id
ren V20654    kids
ren V20693   empst
ren V20696    self
ren V21388   newhd
ren V21420    race
ren V21481       y
ren V21484      ly
ren V20436     wly
ren V20451    tyhw
ren V20601   tyoth
ren V20617   troth
ren V20501    trhw
ren V21493    avhy
ren V20452 giveamt
ren V20453 givechsup
ren V20454 givealim
ren V20477 increlh
ren V20497 increlw
ren V20614 increlofum
ren V21522   marit
ren V21547  weight
ren V20407    food
ren V20409    fout
gen           ftax=0
gen year=1991
tempfile fam91
save `fam91',replace

use "$rawPSIDdata/fam1993", clear
gen truncy=0
gen trunca=0
#delimit;
keep V21603 V21605 V21606 V21608 V21634 V22405 V21602 V22409 V22448 V22451 V23245 V23276 	 
     V23322 V23323 V23324 V21959 V22373 V22397 V22366 
     V23336 V23361 V21707 V21711 V21670
     V21809 V21813 V21810 V21814 V21811 V21812 V21829 V21845 V21861 V21893 V21877 V21909 V21925 V21957 V21941 V22371
     V22366 V22397 V21727 V23278 V23171 V23181 V21622 V21610 V21739 trunc*
	 V22454 V22455 V22156 V22333 V22392
	 V22142 V22143 V22158 V22159 V22319 V22320 V22335 V22336 V21960 V21961 V21962 V22392
	 ;
#delimit cr
ren V22454 unionj 
ren V22455 unioni 

gen asset=V21809+V21813+V21810+V21814+V21811+V21812+V21829+V21845+V21861+V21893+V21877+V21909+V21925+V21957+V21941+V22371
drop V21809 V21813 V21810 V21814 V21811 V21812 V21829 V21845 V21861 V21893 V21877 V21909 V21925 V21957 V21941 V22371
gen  ncars=.
gen   util=.
ren V21739   wages
ren V21610   house
ren V21622    rent
ren V23181   disab
ren V23171  outkid
ren V23278     vet
ren V21727   fstmp
ren V21670   hourw
ren V21603   state
ren V21605    smsa
ren V21606   split
ren V21608    fchg
ren V21634   hours
ren V22405   fsize
ren V21602      id
ren V22409    kids
ren V22448   empst
ren V22451    self
ren V23245   newhd
ren V23276    race
ren V23322       y
ren V23323      ly
ren V23324     wly
ren V21959    tyhw
ren V22373   tyoth
ren V22397   troth
ren V22366    trhw
gen avhy=ly/hours
ren V22142 increlamth
ren V22143 increlperh
ren V22158 incnrelamth
ren V22159 incnrelperh
ren V22319 increlamtw
ren V22320 increlperw
ren V22335 incnrelamtw
ren V22336 incnrelperw
ren V21960 giveamt
ren V21961 givechsup
ren V21962 givealim 
ren V22392 increlofum
ren V23336   marit
ren V23361  weight
ren V21707    food
ren V21711    fout
gen          ftax=0
gen year=1992
tempfile fam92
save `fam92',replace

use "$rawPSIDdata/fam1994er", clear
*NOTE: income variable changed here -- can now have negative income
*NOTE: food/consumption variables changed here? need food stamp amount and extra from food stamp amount
gen truncy=0
gen trunca=0
rename ER2002 id
rename ER2033 house
rename	ER3233 assinthamt
rename	ER3234 assinthper
rename	ER3539 assintsamt
rename	ER3540 assintsper
rename	ER3218 assdivhamt
rename	ER3219 assdivhper
rename	ER3524 assdivsamt
rename	ER3525 assdivsper
rename	ER3248 asstruhamt
rename	ER3249 asstruhper
rename	ER3554 asstrusamt
rename	ER3555 asstrusper
rename	ER3203 assrntamt
rename	ER3204 assrntper
rename	ER4120 assbush
rename	ER4142 assbuss
rename ER3060 fstmpamt
rename ER3061 fstmpper
rename ER3085 foodhomeamt
rename ER3086 foodhomeper
rename ER3078 FSfoodhomeamt
rename ER3079 FSfoodhomeper
rename ER3088 fooddelamt
rename ER3089 fooddelper
rename ER3081 FSfooddelamt
rename ER3082 FSfooddelper	
rename ER3090 foodawayamt
rename ER3091 foodawayper
rename ER3083 FSfoodawayamt
rename ER3084 FSfoodawayper
rename ER4153 inctot
ren ER4156   state
gen smsa=0
ren ER2006   fsize
ren ER2010    kids
ren ER2068   empst
ren ER2074    self
ren ER3706  outkid
rename ER3944 race
rename ER2014 marit
gen tyoth=0
ren ER3431 increlamth
ren ER3432 increlperh
ren ER3446 incnrelamth
ren ER3447 incnrelperh
ren ER3659 increlamtw
ren ER3660 increlperw
ren ER3674 incnrelamtw
ren ER3675 incnrelperw
ren ER3713 giveamt
ren ER3715 givechsup
ren ER3717 givealim
gen increlofum=0
drop ER*
gen year=1993
tempfile fam93
save `fam93',replace


use "$rawPSIDdata/fam1995er", clear
rename ER5002 id
rename ER5032 house
rename	ER6233 assinthamt
rename	ER6234 assinthper
rename	ER6540 assintsamt
rename	ER6541 assintsper
rename	ER6218 assdivhamt
rename	ER6219 assdivhper
rename	ER6525 assdivsamt
rename	ER6526 assdivsper
rename	ER6248 asstruhamt
rename	ER6249 asstruhper
rename	ER6555 asstrusamt
rename	ER6556 asstrusper
rename	ER6203 assrntamt
rename	ER6204 assrntper
rename	ER6960 assbush
rename	ER6982 assbuss
rename ER6059 fstmpamt
rename ER6060 fstmpper
rename ER6084 foodhomeamt
rename ER6085 foodhomeper
rename ER6077 FSfoodhomeamt
rename ER6078 FSfoodhomeper
rename ER6087 fooddelamt
rename ER6088 fooddelper
rename ER6080 FSfooddelamt
rename ER6081 FSfooddelper	
rename ER6089 foodawayamt
rename ER6090 foodawayper
rename ER6082 FSfoodawayamt
rename ER6083 FSfoodawayper
rename ER6993 inctot
ren ER6432 increlamth
ren ER6433 increlperh
ren ER6447 incnrelamth
ren ER6448 incnrelperh
ren ER6661 increlamtw
ren ER6662 increlperw
ren ER6676 incnrelamtw
ren ER6677 incnrelperw
ren ER6715 giveamt
ren ER6717 givechsup
ren ER6719 givealim
gen increlofum=0
ren ER6996	 state
gen smsa=0
ren ER5005    fsize
ren ER5009    kids
ren ER5067    empst
ren ER5073     self
ren ER6708  outkid
rename ER6814 race
rename ER5013 marit
gen tyoth=0
drop ER*
gen year=1994
tempfile fam94
save `fam94',replace


use "$rawPSIDdata/fam1996er", clear
rename ER7002 id
rename ER7032 house
rename	ER8350 assinthamt
rename	ER8351 assinthper
rename	ER8657 assintsamt
rename	ER8658 assintsper
rename	ER8335 assdivhamt
rename	ER8336 assdivhper
rename	ER8642 assdivsamt
rename	ER8643 assdivsper
rename	ER8365 asstruhamt
rename	ER8366 asstruhper
rename	ER8672 asstrusamt
rename	ER8673 asstrusper
rename	ER8320 assrntamt
rename	ER8321 assrntper
rename	ER9211 assbush
rename	ER9233 assbuss
rename ER8156 fstmpamt
rename ER8157 fstmpper
rename ER8181 foodhomeamt
rename ER8182 foodhomeper
rename ER8174 FSfoodhomeamt
rename ER8175 FSfoodhomeper
rename ER8184 fooddelamt
rename ER8185 fooddelper
rename ER8177 FSfooddelamt
rename ER8178 FSfooddelper	
rename ER8186 foodawayamt
rename ER8187 foodawayper
rename ER8179 FSfoodawayamt
rename ER8180 FSfoodawayper
rename ER9244 inctot
ren ER8549 increlamth
ren ER8550 increlperh
ren ER8564 incnrelamth
ren ER8565 incnrelperh
ren ER8778 increlamtw
ren ER8779 increlperw
ren ER8793 incnrelamtw
ren ER8794 incnrelperw
ren ER8833 giveamt
ren ER8835 givechsup
ren ER8837 givealim
gen increlofum=0
ren ER9247   state
gen smsa=0
ren ER7005   fsize
ren ER7009     kids
ren ER7163   empst
ren ER7164 	 empst1
ren	ER7165	 empst2
ren ER7166	 empst3
ren ER7169    self
ren ER8826   outkid
rename ER9060 race
rename ER7013 marit
gen tyoth=0
drop ER*
gen year=1995
tempfile fam95
save `fam95',replace

use "$rawPSIDdata/fam1997er", clear
rename ER10002 id
rename ER10036 house
rename	ER11243 assinthamt
rename	ER11244 assinthper
rename	ER11539 assintsamt
rename	ER11540 assintsper
rename	ER11228 assdivhamt
rename	ER11229 assdivhper
rename	ER11524 assdivsamt
rename	ER11525 assdivsper
rename	ER11258 asstruhamt
rename	ER11259 asstruhper
rename	ER11554 asstrusamt
rename	ER11555 asstrusper
rename	ER11213 assrntamt
rename	ER11214 assrntper
rename	ER12194 assbush
rename	ER12215 assbuss
rename ER11050 fstmpamt
rename ER11051 fstmpper
rename ER11076 foodhomeamt
rename ER11077 foodhomeper
rename ER11068 FSfoodhomeamt
rename ER11069 FSfoodhomeper
rename ER11079 fooddelamt
rename ER11080 fooddelper
rename ER11071 FSfooddelamt
rename ER11072 FSfooddelper
rename ER11081 foodawayamt
rename ER11082 foodawayper
rename ER11073 FSfoodawayamt
rename ER11074 FSfoodawayper
rename ER12079 inctot
ren ER11443 increlamth
ren ER11444 increlperh
ren ER11458 incnrelamth
ren ER11459 incnrelperh
ren ER11660 increlamtw
ren ER11661 increlperw
ren ER11675 incnrelamtw
ren ER11676 incnrelperw
ren ER11715 giveamt
ren ER11717 givechsup
ren ER11719 givealim
gen increlofum=0
ren ER12221   state
gen smsa=0
ren ER10008   fsize
ren ER10012    kids
*must recreate empst
ren ER10081	 empst1
ren	ER10082	 empst2
ren ER10083	 empst3
ren ER10086    self
ren ER11708  outkid
rename ER11848 race
rename ER10016 marit
drop ER*
gen year=1996
tempfile fam96
save `fam96',replace

use "$rawPSIDdata/fam1999er", clear
	rename ER14509 assinthamt
	rename ER14510 assinthper
	rename ER14805 assintsamt
	rename ER14806 assintsper
	rename ER14494 assdivhamt
	rename ER14495 assdivhper
	rename ER14790 assdivsamt
	rename ER14791 assdivsper
	rename ER14524 asstruhamt
	rename ER14525 asstruhper
	rename ER14820 asstrusamt
	rename ER14821 asstrusper
	rename ER14479 assrntamt
	rename ER14480 assrntper
	rename ER16491 assbush
	rename ER16512 assbuss
	rename ER13041 house
	rename ER13004 state
	rename ER16432 smsa
	rename ER13009 fsize
	rename ER13013 kids
	ren ER13205	 empst1
	ren	ER13206	 empst2
	ren ER13207	 empst3
	ren ER13210  self
	ren ER14976 outkid
	rename ER15928 race
	rename ER16423 marit
	rename ER16456 tyoth
	rename ER16435 othFU1ID
	rename ER16436 othFU1rel
	rename ER16438 othFU2ID
	rename ER16439 othFU2rel
	rename ER16441 othFU3ID
	rename ER16442 othFU3rel
	rename ER16444 othFU4ID
	rename ER16445 othFU4rel
	rename ER13002 id
	rename ER16452 inctaxhw
	rename ER16454 inctranhw
	gen inctaxofum=tyoth
	rename ER16458 inctranofum
	rename ER16460 incSS
	rename ER14709 increlamth
	rename ER14710 increlperh
	rename ER14724 incnrelamth
	rename ER14725 incnrelperh
	rename ER14926 increlamtw
	rename ER14927 increlperw
	rename ER14941 incnrelamtw
	rename ER14942 incnrelperw
	gen increlofum=0
	rename ER16463 labor_head
	rename ER16465 labor_wife
	rename ER16462 inctot
	rename ER14983 giveamt
	rename ER14985 givechsup
	rename ER14987 givealim
	rename ER14256 fstmpamt
	rename ER14257 fstmpper	
	rename ER14288 FSfoodhomeamt
	rename ER14289 FSfoodhomeper
	rename ER14295 foodhomeamt
	rename ER14296 foodhomeper
	rename ER14291 FSfooddelamt
	rename ER14292 FSfooddelper	
	rename	ER14298	fooddelamt
	rename	ER14299	fooddelper
	rename ER14293 FSfoodawayamt
	rename ER14294 FSfoodawayper
	rename	ER14300	foodawayamt
	rename	ER14301	foodawayper
	rename	ER13048	houmort1
	rename	ER13063	houmort2
	rename	ER13064	houmort3
	rename	ER13065	hourent
	rename	ER13066	hourentper
	rename	ER13068	hourentwheat
	rename	ER13043	houins
	rename	ER13042	houprop
	rename	ER13086	houelecamt
	rename	ER13087	houelecper
	rename	ER13088	houheatamt
	rename	ER13089	houheatper
	rename	ER13090	houwateramt
	rename	ER13091	houwaterper
	rename	ER13097	houothamt
	rename	ER13098	houothper
	rename	ER13121	carloanamt
	rename	ER13122	carloanper
	rename	ER13118	cardown
	rename	ER13126	carlease
	rename	ER13127	carpayamt
	rename	ER13128	carpayper
	rename	ER13191	transins
	rename	ER13192	transinsper
	rename	ER13195	transrep
	rename	ER13196	transgas
	rename	ER13194	transothveh
	rename	ER13197	transpark
	rename	ER13198	transbus
	rename	ER13199	transtaxi
	rename	ER13200	transoth
	rename	ER13202	educamt
	rename	ER13204	educamtoth
	rename	ER14232	childamt
	rename	ER15781	hlthhosp
	rename	ER15787	hlthdoc
	rename	ER15793	hlthrx
	rename	ER15780	hlthins
drop ER*
gen year=1998
tempfile fam98
save `fam98',replace

use "$rawPSIDdata/fam2001er", clear
	rename ER18666 assinthamt
	rename ER18667 assinthper
	rename ER18982 assintsamt
	rename ER18983 assintsper
	rename ER18650 assdivhamt
	rename ER18651 assdivhper
	rename ER18966 assdivsamt
	rename ER18967 assdivsper
	rename ER18682 asstruhamt
	rename ER18683 asstruhper
	rename ER18998 asstrusamt
	rename ER18999 asstrusper
	rename ER18634 assrntamt
	rename ER18635 assrntper
	rename ER20423 assbush
	rename ER20445 assbuss
	rename ER17044 house
	rename ER17004 state
	rename ER20378 smsa
	rename ER17012 fsize
	rename ER17016 kids
	ren ER17216  empst1
	ren	ER17217	 empst2
	ren ER17218  empst3
	ren ER17221 	self
	ren ER19172 outkid
	rename ER19989 race
	rename ER20369 marit
	rename ER17007 fchg
	rename ER20453 tyoth
	rename ER20381 othFU1ID
	rename ER20382 othFU1rel
	rename ER20384 othFU2ID
	rename ER20385 othFU2rel
	rename ER20387 othFU3ID
	rename ER20388 othFU3rel
	rename ER20390 othFU4ID
	rename ER20391 othFU4rel
	rename ER17002 id
	rename ER18879 increlamth
	rename ER18880 increlperh
	rename ER18895 incnrelamth
	rename ER18896 incnrelperh
	rename ER19111 increlamtw
	rename ER19112 increlperw
	rename ER19127 incnrelamtw
	rename ER19128 incnrelperw
	gen increlofum=0
	rename ER20443 labor_head
	rename ER20448 labor_wife
	rename ER20456 inctot
	rename ER19179 giveamt
	rename ER19181 givechsup
	rename ER19183 givealim
	rename ER18387 fstmpamt
	rename ER18388 fstmpper
	rename ER18421 FSfoodhomeamt
	rename ER18422 FSfoodhomeper
	rename ER18431 foodhomeamt
	rename ER18432 foodhomeper
	rename ER18425 FSfooddelamt
	rename ER18426 FSfooddelper	
	rename	ER18435	fooddelamt
	rename	ER18436	fooddelper
	rename ER18428 FSfoodawayamt
	rename ER18429 FSfoodawayper
	rename	ER18438	foodawayamt
	rename	ER18439	foodawayper
	rename	ER17054	houmort1
	rename	ER17072	houmort2
	rename	ER17073	houmort3
	rename	ER17074	hourent
	rename	ER17075	hourentper
	rename	ER17078	hourentwheat
	rename	ER17048	houins
	rename	ER17046	houprop
	rename	ER17097	houelecamt
	rename	ER17098	houelecper
	rename	ER17099	houheatamt
	rename	ER17100	houheatper
	rename	ER17101	houwateramt
	rename	ER17102	houwaterper
	rename	ER17108	houothamt
	rename	ER17109	houothper
	rename	ER17132	carloanamt
	rename	ER17133	carloanper
	rename	ER17129	cardown
	rename	ER17137	carlease
	rename	ER17138	carpayamt
	rename	ER17139	carpayper
	rename	ER17202	transins
	rename	ER17203	transinsper
	rename	ER17206	transrep
	rename	ER17207	transgas
	rename	ER17205	transothveh
	rename	ER17208	transpark
	rename	ER17209	transbus
	rename	ER17210	transtaxi
	rename	ER17211	transoth
	rename	ER17213	educamt
	rename	ER17215	educamtoth
	rename	ER18362	childamt
	rename	ER19842	hlthhosp
	rename	ER19848	hlthdoc
	rename	ER19854	hlthrx
	rename	ER19841	hlthins
drop ER*
gen year=2000
tempfile fam00
save `fam00',replace

use "$rawPSIDdata/fam2003er", clear
	rename ER22037 assinthamt
	rename ER22038 assinthper
	rename ER22370 assintsamt
	rename ER22371 assintsper
	rename ER22020 assdivhamt
	rename ER22021 assdivhper
	rename ER22353 assdivsamt
	rename ER22354 assdivsper
	rename ER22054 asstruhamt
	rename ER22055 asstruhper
	rename ER22387 asstrusamt
	rename ER22388 asstrusper
	rename ER22003 assrntamt
	rename ER22004 assrntper
	rename ER24110 assbush
	rename ER24112 assbuss
	rename ER21043 house
	rename ER21003 state
	rename ER24145 smsa
	rename ER21016 fsize
	rename ER21020 kids
	ren ER21123	 empst1
	ren	ER21124	 empst2
	ren ER21125	 empst3
	*self-employed question changed here a little
	ren ER21147 self
	ren ER22537 outkid
	rename ER23426 race
	rename ER24150 marit
	rename ER21007 fchg
	rename ER24102 tyoth
	rename ER24158 othFU1ID
	rename ER24159 othFU1rel
	rename ER24161 othFU2ID
	rename ER24162 othFU2rel
	rename ER24164 othFU3ID
	rename ER24165 othFU3rel
	rename ER24167 othFU4ID
	rename ER24168 othFU4rel
	rename ER21002 id
	rename ER22249 increlamth
	rename ER22250 increlperh
	rename ER22265 incnrelamth
	rename ER22266 incnrelperh
	rename ER22484 increlamtw
	rename ER22485 increlperw
	rename ER22500 incnrelamtw
	rename ER22501 incnrelperw	
	gen increlofum=0
	rename ER24116 labor_head
	rename ER24135 labor_wife
	rename ER24099 inctot
	rename ER22544 giveamt
	rename ER22546 givechsup
	rename ER22548 givealim
	rename ER21653 fstmpamt
	rename ER21654 fstmpper
	rename ER21686 FSfoodhomeamt
	rename ER21687 FSfoodhomeper
	rename ER21696 foodhomeamt
	rename ER21697 foodhomeper
	rename ER21690 FSfooddelamt
	rename ER21691 FSfooddelper	
	rename	ER21700	fooddelamt
	rename	ER21701	fooddelper
	rename ER21693 FSfoodawayamt
	rename ER21694 FSfoodawayper
	rename	ER21703	foodawayamt
	rename	ER21704	foodawayper
	rename	ER21053	houmort1
	rename	ER21070	houmort2
	rename	ER21071	houmort3
	rename	ER21072	hourent
	rename	ER21073	hourentper
	rename	ER21076	hourentwheat
	rename	ER21047	houins
	rename	ER21045	houprop
	rename	ER21086	houelecamt
	rename	ER21087	houelecper
	rename	ER21088	houheatamt
	rename	ER21089	houheatper
	rename	ER21090	houwateramt
	rename	ER21091	houwaterper
	rename	ER21097	houothamt
	rename	ER21098	houothper
	rename	ER21771	carloanamt
	rename	ER21772	carloanper
	rename	ER21768	cardown
	rename	ER21775	carlease
	rename	ER21776	carpayamt
	rename	ER21777	carpayper
	rename	ER21838	transins
	rename	ER21839	transinsper
	rename	ER21842	transrep
	rename	ER21843	transgas
	rename	ER21841	transothveh
	rename	ER21844	transpark
	rename	ER21845	transbus
	rename	ER21846	transtaxi
	rename	ER21847	transoth
	rename	ER21849	educamt
	rename	ER21851	educamtoth
	rename	ER21628	childamt
	rename	ER23279	hlthhosp
	rename	ER23285	hlthdoc
	rename	ER23291	hlthrx
	rename	ER23278	hlthins
drop ER*
gen year=2002
tempfile fam02
save `fam02',replace


use "$rawPSIDdata/fam2005er", clear
	rename ER27936 assinth
	rename ER27949 assints
	rename ER27934 assdivh
	rename ER27947 assdivs
	rename ER27938 asstruh
	rename ER27951 asstrus
	egen assrnt=rowtotal(ER27932 ER27945)
	rename ER27911 assbush
	rename ER27941 assbuss
	rename ER25029 house
	rename ER25003 state
	rename ER28044 smsa
	rename ER25016 fsize
	rename ER25020 kids
	ren ER25104	 empst1
	ren	ER25105	 empst2
	ren ER25106	 empst3
	*self-employed question changed here a little 
	ren ER25129 self
	ren ER26518 outkid
	rename ER27393 race
	rename ER28049 marit
	rename ER25007 fchg
	rename ER28009 tyoth
	rename ER28057 othFU1ID
	rename ER28058 othFU1rel
	rename ER28060 othFU2ID
	rename ER28061 othFU2rel
	rename ER28063 othFU3ID
	rename ER28064 othFU3rel
	rename ER28066 othFU4ID
	rename ER28067 othFU4rel
	rename ER25002 id
	rename ER26230 increlamth
	rename ER26231 increlperh
	rename ER26246 incnrelamth
	rename ER26247 incnrelperh
	rename ER26465 increlamtw
	rename ER26466 increlperw
	rename ER26481 incnrelamtw
	rename ER26482 incnrelperw	
	rename ER28026 increlofum
	rename ER27931 labor_head
	rename ER27943 labor_wife
	rename ER28037 inctot
	rename ER26525 giveamt
	rename ER26527 givechsup
	rename ER26529 givealim
	rename ER25655 fstmpamt
	rename ER25656 fstmpper
	rename ER25688 FSfoodhomeamt
	rename ER25689 FSfoodhomeper
	rename ER25698 foodhomeamt
	rename ER25699 foodhomeper
	rename ER25692 FSfooddelamt
	rename ER25693 FSfooddelper	
	rename	ER25702	fooddelamt
	rename	ER25703	fooddelper
	rename ER25695 FSfoodawayamt
	rename ER25696 FSfoodawayper
	rename	ER25705	foodawayamt
	rename	ER25706	foodawayper
	rename	ER25044	houmort1
	rename	ER25061	houmort2
	rename	ER25062	houmort3
	rename	ER25063	hourent
	rename	ER25064	hourentper
	rename	ER25067	hourentwheat
	rename	ER25038	houins
	rename	ER25036	houprop
	rename	ER25082	houelecamt
	rename	ER25083	houelecper
	rename	ER25080	houheatamt
	rename	ER25081	houheatper
	rename	ER25084	houwateramt
	rename	ER25085	houwaterper
	rename  ER25086 houphoneamt
	rename  ER25087 houphoneper
	rename	ER25090	houothamt
	rename	ER25091	houothper
	rename	ER25729	carloanamt
	rename	ER25730	carloanper
	rename	ER25726	cardown
	rename	ER25733	carlease
	rename	ER25734	carpayamt
	rename	ER25735	carpayper
	rename	ER25794	transins
	rename	ER25795	transinsper
	rename	ER25798	transrep
	rename	ER25799	transgas
	rename	ER25797	transothveh
	rename	ER25800	transpark
	rename	ER25801	transbus
	rename	ER25802	transtaxi
	rename	ER25803	transoth
	rename	ER25805	educamt
	rename	ER25807	educamtoth
	rename	ER25628	childamt
	rename	ER27239	hlthhosp
	rename	ER27245	hlthdoc
	rename	ER27251	hlthrx
	rename	ER27238	hlthins
drop ER*
gen year=2004
tempfile fam04
save `fam04',replace


use "$rawPSIDdata/fam2007er", clear
	rename ER40926 assinth
	rename ER40939 assints
	rename ER40924 assdivh
	rename ER40937 assdivs
	rename ER40928 asstruh
	rename ER40941 asstrus
	egen assrnt=rowtotal(ER40922 ER40935)
	rename ER40901 assbush
	rename ER40931 assbuss
	rename ER36029 house
	rename ER36003 state
	rename ER41034 smsa
	rename ER36016 fsize
	rename ER36020 kids
	ren ER36109  empst1
	ren	ER36110  empst2
	ren ER36111  empst3
	*self-employed question changed here a little 
	ren ER36134 self
	ren ER37536 outkid
	rename ER40565 race
	rename ER41039 marit
	rename ER36007 fchg
	rename ER40999 tyoth
	rename ER41047 othFU1ID
	rename ER41048 othFU1rel
	rename ER41050 othFU2ID
	rename ER41051 othFU2rel
	rename ER41053 othFU3ID
	rename ER41054 othFU3rel
	rename ER41056 othFU4ID
	rename ER41057 othFU4rel
	rename ER36002 id
	rename ER37248 increlamth
	rename ER37249 increlperh
	rename ER37264 incnrelamth
	rename ER37265 incnrelperh
	rename ER37483 increlamtw
	rename ER37484 increlperw
	rename ER37499 incnrelamtw
	rename ER37500 incnrelperw	
	rename ER41016 increlofum
	rename ER40921 labor_head
	rename ER40933 labor_wife
	rename ER41027 inctot
	rename ER37543 giveamt
	rename ER37545 givechsup
	rename ER37547 givealim
	rename ER36673 fstmpamt
	rename ER36674 fstmpper
	rename ER36706 FSfoodhomeamt
	rename ER36707 FSfoodhomeper
	rename ER36716 foodhomeamt
	rename ER36717 foodhomeper
	rename ER36710 FSfooddelamt
	rename ER36711 FSfooddelper	
	rename	ER36720	fooddelamt
	rename	ER36721	fooddelper
	rename ER36713 FSfoodawayamt
	rename ER36714 FSfoodawayper
	rename	ER36723	foodawayamt
	rename	ER36724	foodawayper
	rename	ER36044	houmort1
	rename	ER36063	houmort2
	rename	ER36064	houmort3
	rename	ER36065	hourent
	rename	ER36066	hourentper
	rename	ER36069	hourentwheat
	rename	ER36038	houins
	rename	ER36036	houprop
	rename	ER36085	houelecamt
	rename	ER36086	houelecper
	rename	ER36083	houheatamt
	rename	ER36084	houheatper
	rename	ER36089	houwateramt
	rename	ER36090	houwaterper
	rename  ER36091 houphoneamt
	rename  ER36092 houphoneper
	rename	ER36095	houothamt
	rename	ER36096	houothper
	rename	ER36747	transloanamt
	rename	ER36748	carloanper
	rename	ER36744	cardown
	rename	ER36751	carlease
	rename	ER36752	carpayamt
	rename	ER36753	carpayper
	rename	ER36812	transins
	rename	ER36813	transinsper
	rename	ER36816	transrep
	rename	ER36817	transgas
	rename	ER36815	transothveh
	rename	ER36818	transpark
	rename	ER36819	transbus
	rename	ER36820	transtaxi
	rename	ER36821	transoth
	rename	ER36823	educamt
	rename	ER36825	educamtoth
	rename	ER36633	childamt
	rename	ER40414	hlthhosp
	rename	ER40420	hlthdoc
	rename	ER40426	hlthrx
	rename	ER40410	hlthins
drop ER*
gen year=2006
tempfile fam06
save `fam06',replace

use "$rawPSIDdata/fam2009er", clear
	rename ER46834 assinth
	rename ER46847 assints
	rename ER46832 assdivh
	rename ER46845 assdivs
	rename ER46836 asstruh
	rename ER46849 asstrus
	egen assrnt=rowtotal(ER46830 ER46843)
	rename ER46809 assbush
	rename ER46839 assbuss
	rename ER42030 house
	rename ER42003 state
	rename ER46976 smsa
	rename ER42016 fsize
	rename ER42020 kids
	ren ER42140  empst1
	ren	ER42141	 empst2
	ren ER42142	 empst3
	*self-employed question changed here a little 
	ren ER42169 self
	ren ER43527 outkid
	rename ER46543 race
	rename ER46983 marit
	rename ER42007 fchg
	rename ER46907 tyoth
	rename ER46991 othFU1ID
	rename ER46992 othFU1rel
	rename ER46994 othFU2ID
	rename ER46995 othFU2rel
	rename ER46997 othFU3ID
	rename ER46998 othFU3rel
	rename ER47000 othFU4ID
	rename ER47001 othFU4rel
	rename ER42002 id
	rename ER43239 increlamth
	rename ER43240 increlperh
	rename ER43255 incnrelamth
	rename ER43256 incnrelperh
	rename ER43474 increlamtw
	rename ER43475 increlperw
	rename ER43490 incnrelamtw
	rename ER43491 incnrelperw	
	rename ER46924 increlofum
	rename ER46829 labor_head
	rename ER46841 labor_wife
	rename ER46935 inctot
	rename ER43534 giveamt
	rename ER43536 givechsup
	rename ER43538 givealim
	rename ER42692 fstmpamt
	rename ER42693 fstmpper
	rename ER42712 FSfoodhomeamt
	rename ER42713 FSfoodhomeper
	rename ER42722 foodhomeamt
	rename ER42723 foodhomeper
	rename ER42716 FSfooddelamt
	rename ER42717 FSfooddelper	
	rename	ER42726	fooddelamt
	rename	ER42727	fooddelper
	rename ER42719 FSfoodawayamt
	rename ER42720 FSfoodawayper
	rename	ER42729	foodawayamt
	rename	ER42730	foodawayper
	rename	ER42045	houmort1
	rename	ER42078	houmort2
	rename	ER42079	houmort3
	rename	ER42080	hourent
	rename	ER42081	hourentper
	rename	ER42084	hourentwheat
	rename	ER42039	houins
	rename	ER42037	houprop
	rename	ER42114	houelecamt
	rename	ER42115	houelecper
	rename	ER42112	houheatamt
	rename	ER42113	houheatper
	rename	ER42118	houwateramt
	rename	ER42119	houwaterper
	rename  ER42120 houphoneamt
	rename  ER42121 houphoneper
	rename	ER42124	houothamt
	rename	ER42125	houothper
	rename	ER42748	transloanamt
	rename	ER42749	carloanper
	rename	ER42745	cardown
	rename	ER42752	carlease
	rename	ER42753	carpayamt
	rename	ER42754	carpayper
	rename	ER42803	transins
	rename	ER42804	transinsper
	rename	ER42807	transrep
	rename	ER42808	transgas
	rename	ER42806	transothveh
	rename	ER42809	transpark
	rename	ER42810	transbus
	rename	ER42811	transtaxi
	rename	ER42812	transoth
	rename	ER42814	educamt
	rename	ER42816	educamtoth
	rename	ER42652	childamt
	rename	ER46387	hlthhosp
	rename	ER46393	hlthdoc
	rename	ER46399	hlthrx
	rename	ER46383	hlthins
drop ER*
gen year=2008
tempfile fam08
save `fam08',replace
********************************

use "$rawPSIDdata/fam2011er", clear
	rename ER52242 assinth
	rename ER52255 assints
	rename ER52240 assdivh
	rename ER52253 assdivs
	rename ER52244 asstruh
	rename ER52257 asstrus
	egen assrnt=rowtotal(ER52238 ER52251)
	rename ER52217 assbush
	rename ER52247 assbuss
	rename ER47330 house
	rename ER47303 state
	rename ER52400 smsa
	rename ER47316 fsize
	rename ER47320 kids
	ren ER47448  empst1
	ren	ER47449	 empst2
	ren ER47450	 empst3
	*self-employed question changed here a little 
	ren ER47482 self
	ren ER48852 outkid
	rename ER51904 race
	rename ER52407 marit
	rename ER47307 fchg
	rename ER52315 tyoth
	rename ER52415 othFU1ID
	rename ER52416 othFU1rel
	rename ER52418 othFU2ID
	rename ER52419 othFU2rel
	rename ER52421 othFU3ID
	rename ER52422 othFU3rel
	rename ER52424 othFU4ID
	rename ER52425 othFU4rel
	rename ER47302 id
	rename ER48564 increlamth
	rename ER48565 increlperh
	rename ER48580 incnrelamth
	rename ER48581 incnrelperh
	rename ER48799 increlamtw
	rename ER48800 increlperw
	rename ER48815 incnrelamtw
	rename ER48816 incnrelperw	
	rename ER52332 increlofum
	rename ER52237 labor_head
	rename ER52249 labor_wife
	rename ER52343 inctot
	rename ER48859 giveamt
	rename ER48861 givechsup
	rename ER48863 givealim
	rename ER48008 fstmpamt
	rename ER48009 fstmpper
	rename ER48028 FSfoodhomeamt
	rename ER48029 FSfoodhomeper
	rename ER48038 foodhomeamt
	rename ER48039 foodhomeper
	rename ER48032 FSfooddelamt
	rename ER48033 FSfooddelper	
	rename ER48042 fooddelamt
	rename ER48043 fooddelper
	rename ER48035 FSfoodawayamt
	rename ER48036 FSfoodawayper
	rename	ER48045	foodawayamt
	rename	ER48046	foodawayper
	rename	ER47350	houmort1
	rename	ER47352	houmort2
	rename	ER47353	houmort3
	rename	ER47387	hourent
	rename	ER47388	hourentper
	rename	ER47392	hourentwheat
	rename	ER47344	houins
	rename	ER47342	houprop
	rename	ER47417	houelecamt
	rename	ER47418	houelecper
	rename	ER47415	houheatamt
	rename	ER47416	houheatper
	rename	ER47421	houwateramt
	rename	ER47422	houwaterper
	rename  ER47423 houphoneamt
	rename  ER47424 houphoneper
	rename	ER47427	houothamt
	rename	ER47428	houothper
	rename	ER48066	transloanamt
	rename	ER48067	carloanper
	rename	ER48063	cardown
	rename	ER48070	carlease
	rename	ER48071	carpayamt
	rename	ER48072	carpayper
	rename	ER48125	transins
	rename	ER48126	transinsper
	rename	ER48129	transrep
	rename	ER48130	transgas
	rename	ER48128	transothveh
	rename	ER48131	transpark
	rename	ER48132	transbus
	rename	ER48133	transtaxi
	rename	ER48134	transoth
	rename	ER48136	educamt
	rename	ER48138	educamtoth
	rename	ER47970	childamt
	rename	ER51748	hlthhosp
	rename	ER51754	hlthdoc
	rename	ER51760	hlthrx
	rename	ER51744	hlthins
drop ER*
gen year=2010
tempfile fam10
save `fam10',replace
********************************

use "$rawPSIDdata/fam2013er", clear
	rename ER58043 assinth
	rename ER58056 assints
	rename ER58041 assdivh
	rename ER58054 assdivs
	rename ER58045 asstruh
	rename ER58058 asstrus
	egen assrnt=rowtotal(ER58039 ER58052)
	rename ER58018 assbush
	rename ER58048 assbuss
	rename ER53030 house
	rename ER53003 state
	rename ER58218 smsa
	rename ER53016 fsize
	rename ER53020 kids
	ren ER53148  empst1
	ren	ER53149	 empst2
	ren ER53150	 empst3
	*self-employed question changed here a little
	ren ER53182 self
	ren ER54595 outkid
	rename ER57659 race
	rename ER58225 marit
	rename ER53007 fchg
	rename ER58124 tyoth
	rename ER58233 othFU1ID
	rename ER58234 othFU1rel
	rename ER58236 othFU2ID
	rename ER58237 othFU2rel
	rename ER58239 othFU3ID
	rename ER58240 othFU3rel
	rename ER58242 othFU4ID
	rename ER58243 othFU4rel
	rename ER53002 id
	rename ER54258 increlamth
	rename ER54259 increlperh
	rename ER54274 incnrelamth
	rename ER54275 incnrelperh
	rename ER54542 increlamtw
	rename ER54543 increlperw
	rename ER54558 incnrelamtw
	rename ER54559 incnrelperw	
	rename ER58141 increlofum
	rename ER58038 labor_head
	rename ER58050 labor_wife
	rename ER58152 inctot
	rename ER54602 giveamt
	rename ER54604 givechsup
	rename ER54606 givealim
	rename ER53705 fstmpamt
	rename ER53706 fstmpper
	rename ER53725 FSfoodhomeamt
	rename ER53726 FSfoodhomeper
	rename ER53735 foodhomeamt
	rename ER53736 foodhomeper
	rename ER53729 FSfooddelamt
	rename ER53730 FSfooddelper	
	rename ER53739 fooddelamt
	rename ER53740 fooddelper
	rename ER53732 FSfoodawayamt
	rename ER53733 FSfoodawayper
	rename	ER53742	foodawayamt
	rename	ER53743	foodawayper
	rename	ER53050	houmort1
	rename	ER53052	houmort2
	rename	ER53053	houmort3
	rename	ER53087	hourent
	rename	ER53088	hourentper
	rename	ER53092	hourentwheat
	rename	ER53044	houins
	rename	ER53042	houprop
	rename	ER53117	houelecamt
	rename	ER53118	houelecper
	rename	ER53115	houheatamt
	rename	ER53116	houheatper
	rename	ER53121	houwateramt
	rename	ER53122	houwaterper
	rename  ER53123 houphoneamt
	rename  ER53124 houphoneper
	rename	ER53127	houothamt
	rename	ER53128	houothper
	rename	ER53762	transloanamt
	rename	ER53763	carloanper
	rename	ER53759	cardown
	rename	ER53766	carlease
	rename	ER53767	carpayamt
	rename	ER53768	carpayper
	rename	ER53819	transins
	rename	ER53820	transinsper
	rename	ER53823	transrep
	rename	ER53824	transgas
	rename	ER53822	transothveh
	rename	ER53825	transpark
	rename	ER53826	transbus
	rename	ER53827	transtaxi
	rename	ER53828	transoth
	rename	ER53830	educamt
	rename	ER53832	educamtoth
	rename	ER53682	childamt
	rename	ER57491	hlthhosp //last year (previous was 2 yrs)
	rename	ER57497	hlthdoc
	rename	ER57503	hlthrx
	rename	ER58212D7 hlthins 
drop ER*
gen year=2012
tempfile fam12
save `fam12',replace

**********************************************


use "$rawPSIDdata/fam2015er", clear
	rename ER65221 assinth
	rename ER65249 assints
	rename ER65219 assdivh
	rename ER65247 assdivs
	rename ER65223 asstruh
	rename ER65251 asstrus
	egen assrnt=rowtotal(ER65217 ER65245)
	rename ER65198 assbush
	rename ER65226 assbuss
	rename ER60031 house
	rename ER60003 state
	rename ER65454 smsa
	rename ER60016 fsize
	rename ER60021 kids
	ren ER60163  empst1
	ren	ER60164	 empst2
	ren ER60165  empst3
	*self-employed question changed here a little 
	ren ER60197 self
	ren ER61706 outkid
	rename ER64810 race
	rename ER65461 marit
	rename ER60007 fchg
	rename ER65321 tyoth
	rename ER65469 othFU1ID
	rename ER65470 othFU1rel
	rename ER65472 othFU2ID
	rename ER65473 othFU2rel
	rename ER65475 othFU3ID
	rename ER65476 othFU3rel
	rename ER65478 othFU4ID
	rename ER65479 othFU4rel
	rename ER60002 id
	rename ER61300 increlamth
	rename ER61301 increlperh
	rename ER61316 incnrelamth
	rename ER61317 incnrelperh
	rename ER61653 increlamtw
	rename ER61654 increlperw
	rename ER61669 incnrelamtw
	rename ER61670 incnrelperw	
	rename ER65338 increlofum
	rename ER65216 labor_head
	rename ER65244 labor_wife
	rename ER65349 inctot
	rename ER61713 giveamt
	rename ER61715 givechsup
	rename ER61717 givealim
	rename ER60720 fstmpamt
	rename ER60721 fstmpper
	rename ER60740 FSfoodhomeamt
	rename ER60741 FSfoodhomeper
	rename ER60750 foodhomeamt
	rename ER60751 foodhomeper
	rename ER60744 FSfooddelamt
	rename ER60745 FSfooddelper	
	rename ER60754 fooddelamt
	rename ER60755 fooddelper
	rename ER60747 FSfoodawayamt
	rename ER60748 FSfoodawayper
	rename	ER60757	foodawayamt
	rename	ER60758	foodawayper
	rename	ER60051	houmort1
	rename	ER60053	houmort2
	rename	ER60054	houmort3
	rename	ER60088	hourent
	rename	ER60089	hourentper
	rename	ER60093	hourentwheat
	rename	ER60045	houins
	rename	ER60043	houprop
	rename	ER60112	houelecamt
	rename	ER60113	houelecper
	rename	ER60110	houheatamt
	rename	ER60111	houheatper
	rename	ER60116	houwateramt
	rename	ER60117	houwaterper
	rename  ER60118 houphoneamt
	rename  ER60119 houphoneper
	rename	ER60122	houothamt
	rename	ER60123 houothper
	rename	ER60821	transloanamt
	rename	ER60822	carloanper
	rename	ER60818	cardown
	rename	ER60825	carlease
	rename	ER60826	carpayamt
	rename	ER60827	carpayper
	rename	ER60878	transins
	rename	ER60879	transinsper
	rename	ER60881	transrep //12 months (previous was 1 month)
	rename	ER60883	transgas
	rename	ER60882	transothveh
	rename	ER60884	transpark
	rename	ER60885	transbus
	rename	ER60886	transtaxi
	rename	ER60887	transoth
	rename	ER60889	educamt
	rename	ER60891	educamtoth
	rename	ER60697	childamt
	rename	ER64613	hlthhosp //last year (previous was 2 yrs)
	rename	ER64619	hlthdoc
	rename	ER64625	hlthrx
	rename	ER65443	hlthins 
	drop ER*
gen year=2014
tempfile fam14
save `fam14',replace

**********************************************

use `fam67', clear
local i=68
forval i=68/96 {
	append using `fam`i''
}
append using `fam98'
append using `fam00'
append using `fam02'
append using `fam04'
append using `fam06'
append using `fam08'
append using `fam10'
append using `fam12'
append using `fam14'
sort id year
tempfile fam
save `fam', replace

**********************************************
*INDIVIDUAL LEVEL*
**********************************************
use "$rawPSIDdata/ind2017er.dta", clear

gen latsample=(ER30001>=7001 & ER30001<=9309)
gen seosample=(ER30001>=5000 & ER30001<=7000)
gen immsample=(ER30001>=3001 & ER30001<=3511)

*id is the family interview number for that specific year
ren ER30001 id67
ren ER30020 id68
ren ER30043 id69
ren ER30067 id70 
ren ER30091 id71 
ren ER30117 id72 
ren ER30138 id73
ren ER30160 id74
ren ER30188 id75
ren ER30217 id76
ren ER30246 id77
ren ER30283 id78
ren ER30313 id79
ren ER30343 id80
ren ER30373 id81
ren ER30399 id82
ren ER30429 id83
ren ER30463 id84
ren ER30498 id85
ren ER30535 id86
ren ER30570 id87
ren ER30606 id88
ren ER30642 id89
ren ER30689 id90
ren ER30733 id91
ren ER30806 id92
ren ER33101 id93
ren ER33201 id94
ren ER33301 id95
ren ER33401 id96
ren ER33501 id98
ren ER33601 id100
ren ER33701 id102
ren ER33801 id104
ren ER33901 id106
ren ER34001 id108
ren ER34101 id110
ren ER34201 id112
ren ER34301 id114

*sequence number=status: whether living/dead/institution/moved away/etc
rename ER30021 seqnum68
rename ER30044 seqnum69
rename ER30068 seqnum70
rename ER30092 seqnum71
rename ER30118 seqnum72
rename ER30139 seqnum73
rename ER30161 seqnum74
rename ER30189 seqnum75
rename ER30218 seqnum76
rename ER30247 seqnum77
rename ER30284 seqnum78
rename ER30314 seqnum79
rename ER30344 seqnum80
rename ER30374 seqnum81
rename ER30400 seqnum82
rename ER30430 seqnum83
rename ER30464 seqnum84
rename ER30499 seqnum85
rename ER30536 seqnum86
rename ER30571 seqnum87
rename ER30607 seqnum88
rename ER30643 seqnum89
rename ER30690 seqnum90
rename ER30734 seqnum91
rename ER30807 seqnum92
rename ER33102 seqnum93
rename ER33202 seqnum94
rename ER33302 seqnum95
rename ER33402 seqnum96
rename ER33502 seqnum98
rename ER33602 seqnum100
rename ER33702 seqnum102
rename ER33802 seqnum104
rename ER33902 seqnum106
rename ER34002 seqnum108
rename ER34102 seqnum110
rename ER34202 seqnum112
rename ER34302 seqnum114
rename ER30003 relhead67
rename ER30022 relhead68
rename ER30045 relhead69
rename ER30069 relhead70
rename ER30093 relhead71
rename ER30119 relhead72
rename ER30140 relhead73
rename ER30162 relhead74
rename ER30190 relhead75
rename ER30219 relhead76
rename ER30248 relhead77
rename ER30285 relhead78
rename ER30315 relhead79
rename ER30345 relhead80
rename ER30375 relhead81
rename ER30401 relhead82
rename ER30431 relhead83
rename ER30465 relhead84
rename ER30500 relhead85
rename ER30537 relhead86
rename ER30572 relhead87
rename ER30608 relhead88
rename ER30644 relhead89
rename ER30691 relhead90
rename ER30735 relhead91
rename ER30808 relhead92
rename ER33103 relhead93
rename ER33203 relhead94
rename ER33303 relhead95
rename ER33403 relhead96
rename ER33503 relhead98
rename ER33603 relhead100
rename ER33703 relhead102
rename ER33803 relhead104
rename ER33903 relhead106
rename ER34003 relhead108
rename ER34103 relhead110
rename ER34203 relhead112
rename ER34303 relhead114

*NO 1969 EDUCATION
rename	ER30010	educ67
rename	ER30052	educ69
rename	ER30076	educ70
rename	ER30100	educ71
rename	ER30126	educ72
rename	ER30147	educ73
rename	ER30169	educ74
rename	ER30197	educ75
rename	ER30226	educ76
rename	ER30255	educ77
rename	ER30296	educ78
rename	ER30326	educ79
rename	ER30356	educ80
rename	ER30384	educ81
rename	ER30413	educ82
rename	ER30443	educ83
rename	ER30478	educ84
rename	ER30513	educ85
rename	ER30549	educ86
rename	ER30584	educ87
rename	ER30620	educ88
rename	ER30657	educ89
rename	ER30703	educ90
rename	ER30748	educ91
rename	ER30820	educ92
rename	ER33115	educ93
rename	ER33215	educ94
rename	ER33315	educ95
rename	ER33415	educ96
rename	ER33516	educ98
rename	ER33616	educ100
rename	ER33716	educ102
rename	ER33817	educ104
rename	ER33917	educ106
rename	ER34020	educ108
rename  ER34119 educ110
rename ER34230 educ112
rename ER34349 educ114

*AGE
rename ER30004 age67
rename ER30023 age68
rename ER30046 age69
rename ER30070 age70
rename ER30094 age71
rename ER30120 age72
rename ER30141 age73
rename ER30163 age74
rename ER30191 age75
rename ER30220 age76
rename ER30249 age77
rename ER30286 age78
rename ER30316 age79
rename ER30346 age80
rename ER30376 age81
rename ER30402 age82
rename ER30432 age83
rename ER30466 age84
rename ER30501 age85
rename ER30538 age86
rename ER30573 age87
rename ER30609 age88
rename ER30645 age89
rename ER30692 age90
rename ER30736 age91
rename ER30809 age92
rename ER33104 age93
rename ER33204 age94
rename ER33304 age95
rename ER33404 age96
rename ER33504 age98
rename ER33604 age100
rename ER33704 age102
rename ER33804 age104
rename ER33904 age106
rename ER34004 age108
rename ER34104 age110
rename ER34204 age112
rename ER34305 age114

rename ER30002 IDperson
rename ER32000 sex

keep id* relhead* seqnum* educ* age* IDperson seosample immsample latsample sex

gen IDorigfam=id67
gen person=IDorigfam*1000+IDperson

reshape long id educ age seqnum relhead,i(person) j(year)
replace year=1900+year

drop if age==0 //not in sample yet

compress
sort id year

*merge family data (family-year) onto this individual data (indiv-fam-year)
merge m:1 id year using `fam'
tab _merge					 
drop if _merge!=3			 
drop _merge
save "PSID_fulldata.dta", replace

